
/**
 * @author Hans Von
 * @version 1.0
 * 
 *          Pila.h.
 * 
 */
 typedef char String[50];

struct nodo *head = NULL, *tail = NULL;

struct nodo {
	String dato;
	struct nodo *sig;
};

void push(String s) {
	struct nodo *n;
	n = (struct nodo *) malloc(sizeof(struct nodo));
	if (n != NULL) {
		strcpy(n->dato, s);
		n->sig = head;
		head = n;
		if (tail == NULL) {
			tail = head;
		}
	}
}

struct nodo pop() {

	struct nodo *temp;

	if (head != NULL) {
		temp = head;
		head = head->sig;
		if (head == NULL) {
			tail = NULL;
			temp->sig = NULL;
		}
	}
	return *temp;
}

int vacia() {
	return (head == NULL ? 1 : 0);
}

void recorreLista() {
	struct nodo *p;

	if (vacia()) {
		printf("La pila esta vacia.\n");
	} else {
		p = head;
		while (p) {
			printf("%s\n", p->dato);
			p = p->sig;
		}
		printf("\n");
	}
}
